<% for (var css in htmlWebpackPlugin.files.css) { %>
  <% var basename = htmlWebpackPlugin.files.css[css].split('/').reverse()[0]; %>
  <% var chunkName = basename.replace('.scss', '').replace('.css', '').replace('.styleLiquid', ''); %>
  <% var isLiquidStyle = /.liquidStyle.css$/.test(basename) %>
  <% if (htmlWebpackPlugin.options.isDevServer === true && !basename.includes('.styleLiquid')) { %>
    <% var src = htmlWebpackPlugin.files.css[css] %>
  <% } else { %>
    <% var src = `{{ '${basename}' | asset_url }}` %>
  <% } %>
  <% if (typeof htmlWebpackPlugin.options.liquidTemplates[chunkName] !== 'undefined') { %>
    <% var chunkTemplate = htmlWebpackPlugin.options.liquidTemplates[chunkName] %>
    <% if (chunkTemplate.includes('customers/') || chunkTemplate.includes('customers\\')) { %>
      {%- if template == 'customers/<%= chunkName.split('.').slice(1).join('.') %>' -%}
        <link type="text/css" href="<%= src %>" rel="stylesheet">
      {%- else -%}
        <link rel="prefetch" href="<%= src %>" as="style">
      {%- endif -%}
    <% } else { %>
      {%- if template == '<%= chunkName.split('.').slice(1).join('.') %>' -%}
        <link type="text/css" href="<%= src %>" rel="stylesheet">
      {%- else -%}
        <link rel="prefetch" href="<%= src %>" as="style">
      {%- endif -%}
    <% } %>
  <% } else if (typeof htmlWebpackPlugin.options.liquidLayouts[chunkName] !== 'undefined') { %>
    {%- if layout == '<%= chunkName.split('.')[1] %>' -%}
      <link type="text/css" href="<%= src %>" rel="stylesheet">
    {%- else -%}
      <link rel="prefetch" href="<%= src %>" as="style">
    {%- endif -%}
  <% } else if (chunkName.split('@').length > 1) { %>
    <% var pages = chunkName.split('@').slice(1) %>
    <% var conditions = [] %>
    <% pages.forEach(function(page){ %>
      <% var pageTemplate = htmlWebpackPlugin.options.liquidTemplates[page] %>
      <% if (typeof pageTemplate !== 'undefined') { %>
        <% if (pageTemplate.includes('customers/') || pageTemplate.includes('customers\\')) { %>
          <% conditions.push("template == 'customers/" + page.split('.').slice(1).join('.') + "'") %>
        <% } else { %>
          <% conditions.push("template == '" + page.split('.').slice(1).join('.') + "'") %>
        <% } %>
      <% } else if (typeof htmlWebpackPlugin.options.liquidLayouts[page] !== 'undefined') { %>
        <% conditions.push("layout == '" + page.split('.')[1] + "'") %>
      <% } %>
    <% }); %>
    {%- if <%= conditions.join(' or ') %> -%}
      <link type="text/css" href="<%= src %>" rel="stylesheet">
    {%- else -%}
      <link rel="prefetch" href="<%= src %>" as="style">
    {%- endif -%}
  <% } else { %>
    <link type="text/css" href="<%= src %>" rel="stylesheet">
  <% } %>
<% } %>
